package com.kun.service;

import com.kun.OrderService;
import com.kun.RpcService;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Random;

@RpcService(OrderService.class) // 指定远程接口
public class OrderServiceImpl implements OrderService {

    public String createOrder(Integer productId, double weight) {

        // 业务逻辑
        //...
        System.out.println("购买了" + productId + "产品，数量为" + weight + "件。");

        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMMddhhmmSS");
        String dateString = simpleDateFormat.format(new Date());

        StringBuffer stringBuffer = new StringBuffer();

        for (int i = 0; i < 5; i++) {
            stringBuffer.append(new Random().nextInt(10));
        }

        return "O" + dateString + stringBuffer.toString();
    }

}
